const { exec } = require("child_process");
const { logger } = require("./logger");
const { sendWebhook } = require("./webhook");

exec("CocosCreator.exe --path ../ --build debug=false;platform=wechatgame", {
    maxBuffer: 1024 * 1024 * 1024,
}, (error, stdout, stderr) => {
    if (error) {
        logger.error(`cocos 编译失败`, error);
        sendWebhook(`cocos 编译失败`);
        return;
    }
    if (stderr) {
        logger.error(`cocos 编译失败`, stderr);
        sendWebhook(`cocos 编译失败`);
        return;
    }
    logger.log(`编译成功`);
});